/*
 * @lc app=leetcode.cn id=1876 lang=javascript
 *
 * [1876] 长度为三且各字符不同的子字符串
 */

// @lc code=start
/**
 * @param {string} s
 * @return {number}
 */
var countGoodSubstrings = function (s) {
  if (s.length < 3) return 0;
  const map = {};
  let count = 0;
  for (let i = 2; i < s.length; i++) {
    if (s[i - 2] !== s[i - 1]
      && s[i - 2] !== s[i]
      && s[i - 1] !== s[i]
    ) {
      count++;
    }
  }
  return count;
};
// @lc code=end

